﻿/*!	@file	r_draw_vertexbuffer_dx11.h
	@brief	頂点バッファ
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _R_DRAW_VERTEXBUFFER_DX11_H_
#define _R_DRAW_VERTEXBUFFER_DX11_H_

#include "../r_draw_vertexbuffer.h"
#if R_TARGET_UNIQUEIS(R_TARGET_UNIQUE_WINDX11)
#include <d3d11.h>

namespace r{
	namespace draw{
		namespace dx11{
			class CoreDX11;
		}
	}
}
namespace r{
	namespace draw{
		namespace dx11{
			//! 頂点バッファ
			/*!
			*/
			class VertexBufferDX11 : public r::draw::VertexBuffer
			{
				RRTTI_REFLECTION_DECLARE
				friend class r::draw::dx11::CoreDX11;
			__r_serialize:
				//! RTTI用未使用
				VertexBufferDX11();
			protected:
				//! コンストラクタ
				/*!
				@param	_stride		[in]	1頂点のデータサイズ
				@param	_numVertex	[in]	頂点数
				*/
				VertexBufferDX11 ( r_ui32 _stride, r_ui32 _numVertex );
				//! デストラクタ
				virtual ~VertexBufferDX11();
			public:
				//! バッファへの書き込みを可能にする
				/*! この関数はスレッドセーフでは無いのでメインスレッドから安全に呼び出す必要がある
				*/
				virtual	r_bool		map();
				//! バッファへの書き込みを完了する
				/*! この関数はスレッドセーフでは無いのでメインスレッドから安全に呼び出す必要がある
				*/
				virtual	void		unMap();
			public:
				//! 頂点情報を書き込む
				/*!
				*/
				virtual	void		setVertex ( r_ui32 index, const void* value );
				virtual	void		setVertex ( const void* value );
				virtual void*		getBufferAddr()const;
			public:
				//! D3Dのバッファを参照する
				ID3D11Buffer*		getVertexBuffer() const;
			protected:
			private:
				//! 頂点作成一時領域
				r_ui8*				tempBuffer;
				//! D3Dのバッファ
				ID3D11Buffer*		vertexBuffer;
			};
		}
	}
}

#endif // R_TARGET_UNIQUEIS(R_TARGET_UNIQUE_WINDX11)

#endif // _R_DRAW_VERTEXBUFFER_DX11_H_
